﻿<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 11">
<meta name=Originator content="Microsoft Word 11">
<link rel=File-List href="strings.files/filelist.xml">
<title>Strings</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>MC SYSTEM</o:Author>
  <o:LastAuthor>MC SYSTEM</o:LastAuthor>
  <o:Revision>38</o:Revision>
  <o:TotalTime>449</o:TotalTime>
  <o:Created>2014-10-23T15:05:00Z</o:Created>
  <o:LastSaved>2014-10-23T16:00:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Words>861</o:Words>
  <o:Characters>4908</o:Characters>
  <o:Company>MC SYSTEM</o:Company>
  <o:Lines>40</o:Lines>
  <o:Paragraphs>11</o:Paragraphs>
  <o:CharactersWithSpaces>5758</o:CharactersWithSpaces>
  <o:Version>11.5606</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:SpellingState>Clean</w:SpellingState>
  <w:GrammarState>Clean</w:GrammarState>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:Compatibility>
   <w:UseFELayout/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-alt:SimSun;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:3 680460288 22 0 262145 0;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:-520077569 -1073717157 41 0 66047 0;}
@font-face
	{font-family:"\@宋体";
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:3 680460288 22 0 262145 0;}
@font-face
	{font-family:新宋体;
	panose-1:2 1 6 9 3 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:modern;
	mso-font-pitch:fixed;
	mso-font-signature:3 680460288 22 0 262145 0;}
@font-face
	{font-family:"\@新宋体";
	panose-1:2 1 6 9 3 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:modern;
	mso-font-pitch:fixed;
	mso-font-signature:3 680460288 22 0 262145 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;}
h4
	{mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	mso-outline-level:4;
	font-size:12.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;
	font-weight:bold;}
h5
	{mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	mso-outline-level:5;
	font-size:10.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;
	font-weight:bold;}
p.MsoList2, li.MsoList2, div.MsoList2
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:5.0pt;
	margin-bottom:.0001pt;
	mso-para-margin-top:0cm;
	mso-para-margin-right:0cm;
	mso-para-margin-bottom:0cm;
	mso-para-margin-left:2.0gd;
	mso-para-margin-bottom:.0001pt;
	text-indent:-10.0pt;
	mso-char-indent-count:-2.0;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;}
p.MsoBodyText, li.MsoBodyText, div.MsoBodyText
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;}
p.MsoBodyTextIndent, li.MsoBodyTextIndent, div.MsoBodyTextIndent
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:21.0pt;
	mso-para-margin-top:0cm;
	mso-para-margin-right:0cm;
	mso-para-margin-bottom:6.0pt;
	mso-para-margin-left:2.0gd;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;}
p.MsoBodyTextFirstIndent2, li.MsoBodyTextFirstIndent2, div.MsoBodyTextFirstIndent2
	{mso-style-parent:正文文本缩进;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:21.0pt;
	mso-para-margin-top:0cm;
	mso-para-margin-right:0cm;
	mso-para-margin-bottom:6.0pt;
	mso-para-margin-left:2.0gd;
	text-indent:21.0pt;
	mso-char-indent-count:2.0;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;
	text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
	{color:blue;
	text-decoration:underline;
	text-underline:single;}
p
	{mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;}
code
	{mso-ansi-font-size:12.0pt;
	mso-bidi-font-size:12.0pt;
	font-family:宋体;
	mso-ascii-font-family:宋体;
	mso-fareast-font-family:宋体;
	mso-hansi-font-family:宋体;
	mso-bidi-font-family:宋体;}
pre
	{mso-style-link:"HTML 预设格式 Char";
	margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
	font-size:12.0pt;
	font-family:宋体;
	mso-bidi-font-family:宋体;}
tt
	{mso-ansi-font-size:12.0pt;
	mso-bidi-font-size:12.0pt;
	font-family:宋体;
	mso-ascii-font-family:宋体;
	mso-fareast-font-family:宋体;
	mso-hansi-font-family:宋体;
	mso-bidi-font-family:宋体;}
span.HTMLChar
	{mso-style-name:"HTML 预设格式 Char";
	mso-style-locked:yes;
	mso-style-link:"HTML 预设格式";
	mso-ansi-font-size:12.0pt;
	mso-bidi-font-size:12.0pt;
	font-family:宋体;
	mso-ascii-font-family:宋体;
	mso-fareast-font-family:宋体;
	mso-hansi-font-family:宋体;
	mso-bidi-font-family:宋体;
	mso-ansi-language:EN-US;
	mso-fareast-language:ZH-CN;
	mso-bidi-language:AR-SA;}
span.apple-converted-space
	{mso-style-name:apple-converted-space;}
span.dstring
	{mso-style-name:d_string;}
span.dcomment
	{mso-style-name:d_comment;}
span.dhata
	{mso-style-name:d_hata;}
span.highlight
	{mso-style-name:highlight;}
span.SpellE
	{mso-style-name:"";
	mso-spl-e:yes;}
span.GramE
	{mso-style-name:"";
	mso-gram-e:yes;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:42.55pt;
	mso-footer-margin:49.6pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:普通表格;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<![endif]--><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="19458"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=ZH-CN link=blue vlink=blue style='tab-interval:21.0pt'>

<div class=Section1>

<h4 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;vertical-align:baseline'><span style='font-size:18.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033'>字符串</span><span
lang=EN-US style='font-size:18.0pt;font-family:Arial;color:#000033'><o:p></o:p></span></h4>

<p style='outline: 0px;orphans: auto;text-align:start;widows: auto;-webkit-text-stroke-width: 0px;
background-position:initial initial;background-repeat:initial initial;
word-spacing:0px'>到目前为至，在我们看到的好多的程序中都用到了字符串。 字符串是在最后三章中介绍的两种功能的组合：字符和数组。在最简单的定义中，字符串只不过是字符数组。例如，<span
lang=EN-US>char[]</span>是字符串类型。</p>

<p>这个简单的定义可能会误导。正如我们在“字符”篇中已经看到，<span lang=EN-US>D</span>具有三个单独的字符类型。这些字符类型的数组导致三个单独的字符串类型，其中一些可能会在一些字符串操作上有出人意料的结果。</p>

<p><span class=SpellE><b style='mso-bidi-font-weight:normal'><span lang=EN-US
style='font-size:18.0pt'>readln</span></b></span><b style='mso-bidi-font-weight:
normal'><span style='font-size:18.0pt'>和<span lang=EN-US>chomp,</span>代替<span
class=SpellE><span lang=EN-US>readf</span></span><span lang=EN-US><o:p></o:p></span></span></b></p>

<p>从控制台读字符串您会有一些惊奇。<span class=MsoHyperlink><span lang=EN-US style='color:windowtext;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<p>作为字符数组，字符串能包含像<span lang=EN-US>'\n'</span>这样的控制字符。当从输入中读取字符串，控制台输入结束时按的<span
lang=EN-US>Enter</span>键对应的控制字符将变成字符串的一部分。究其原因，是因为没有办法告诉<span class=SpellE><span
lang=EN-US>readf</span></span><span lang=EN-US>()</span>要读取多少字符，它继续读取，直到整个输入结束。因而<span
class=SpellE><span lang=EN-US>readf</span></span><span lang=EN-US>()</span>不能如愿读取字符串：</p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>import</span></span><span
lang=EN-US style='color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> <span class=SpellE>std.stdio</span>;</span><span lang=EN-US
style='color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span lang=EN-US
style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>void</span></span><span lang=EN-US
style='color:black'> main()<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'>{<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px'><span class=GramE><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>char</span><span lang=EN-US style='color:black'>[</span></span><span
lang=EN-US>] name;<o:p></o:p></span></pre></span><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>write(</span></span><span style='outline: 0px'><span lang=EN-US
style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&quot;What is your name? &quot;</span></span><span
lang=EN-US style='color:black'>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>readf</span></span><span class=GramE>(</span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot; %s&quot;</span></span><span
lang=EN-US style='color:black'>, &amp;name);<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;Hello &quot;</span></span><span
lang=EN-US style='color:black'>, name, </span><span style='outline: 0px'><span
lang=EN-US style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;!&quot;</span></span><span
lang=EN-US style='color:black'>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'>}<o:p></o:p></span></pre></div>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
class=HTMLChar><span style='background:white'>用户在名称后按下<span lang=EN-US>Enter</span>键不会结束输入。<span
class=SpellE><span lang=EN-US>readf</span></span><span lang=EN-US>()</span></span></span><span
style='background:white'>继续<span srcinfo="102:109" dstinfo="32:33" paragraphname=paragraph0
style='orphans: auto;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px' id="ouHighlight__102_109TO32_33"></span>等待<span srcinfo="111:114" dstinfo="34:35"
paragraphname=paragraph0 style='orphans: auto;widows: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px' id="ouHighlight__111_114TO34_35"></span>新输入的<span srcinfo="116:125"
dstinfo="37:38" paragraphname=paragraph0 style='orphans: auto;widows: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'
id="ouHighlight__116_125TO37_38"></span>字符<span srcinfo="130:132" dstinfo="39:40"
paragraphname=paragraph0 style='orphans: auto;widows: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px' id="ouHighlight__130_132TO39_40"></span>添加<span srcinfo="134:135"
dstinfo="41:41" paragraphname=paragraph0 style='orphans: auto;widows: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'
id="ouHighlight__134_135TO41_41"></span>到<span srcinfo="141:146" dstinfo="42:44"
paragraphname=paragraph0 style='orphans: auto;widows: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px' id="ouHighlight__141_146TO42_44"></span>字符串<span
style='orphans: auto;widows: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px' id="noHighlight_0.11092281457968056"></span>：</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#E0E0E0;
margin-left:12.0pt;margin-right:12.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:#E0E0E0;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>What is your name? <span
class=SpellE>Mert</span></span></b><b><span lang=EN-US style='font-size:10.0pt'><o:p></o:p></span></b></pre><pre
style='background:#E0E0E0;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><b><span
lang=EN-US style='font-size:10.0pt;color:black'><span style='mso-spacerun:yes'>  </span><span style='mso-spacerun:yes'> </span></span></b><span
style='outline: 0px'><b><span style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>← 虽然按了<span lang=EN-US>Enter</span>键，但输入没有中断</span></b><b><span
lang=EN-US style='font-size:10.0pt;color:black'><o:p></o:p></span></b></pre><pre
style='background:#E0E0E0;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><b><span
lang=EN-US style='font-size:10.0pt;color:black'><span style='mso-spacerun:yes'>  </span><span style='mso-spacerun:yes'> </span></span></b><span
style='outline: 0px'><b><span style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>←<span lang=EN-US> (</span>让我们假设在诸位第二次按了<span
lang=EN-US>Enter</span>键<span lang=EN-US>)</span></span></span></b><b><span
lang=EN-US style='font-size:10.0pt;color:black'><o:p></o:p></span></b></pre></div>

<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
class=HTMLChar><span style='background:white'>在控制台结束标准输入流的一种方法是在<span
lang=EN-US>Unix</span>系统下按<span lang=EN-US>Ctrl-D</span>，在<span lang=EN-US>Windows</span>系统下按<span
lang=EN-US>Ctrl-Z</span>。如果用户最后结束这种方式的输入，我们看到新行符已作为部分字符串被读取：</span></span><span
class=MsoHyperlink><span lang=EN-US style='color:windowtext;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#E0E0E0;
margin-left:12.0pt;margin-right:12.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:#E0E0E0;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><b><span lang=EN-US
style='font-size:10.0pt;color:black'>Hello <span class=SpellE>Mert</span></span></b><b><span
lang=EN-US style='font-size:10.0pt;mso-bidi-font-size:12.0pt;color:black'><o:p></o:p></span></b></pre><pre
style='background:#E0E0E0;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><b><span
lang=EN-US style='font-size:10.0pt;color:black'><span style='mso-spacerun:yes'>  </span><span style='mso-spacerun:yes'> </span></span></b><span
style='outline: 0px'><b><span style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>← 名字之后的新行符</span></b><b><span
lang=EN-US style='font-size:10.0pt;color:black'><o:p></o:p></span></b></pre><pre
style='background:#E0E0E0;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>! <span style='mso-spacerun:yes'> </span></span></b><span
style='outline: 0px'><b><span style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>←<span lang=EN-US> (</span>在感叹号前也是新行<span
lang=EN-US>)</span></span></span></b><b><span lang=EN-US style='font-size:10.0pt;
color:black'><o:p></o:p></span></b></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>感叹号出现在了那些字符之后，而不是打印在名字右侧。</span><span class=MsoHyperlink><span
lang=EN-US style='font-family:"Times New Roman";color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;mso-line-height-alt:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span class=SpellE><code style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>readln</span></b></code></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>()</span></b></code><code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>更适合读取字符串，它是</span></code><code><span
lang=EN-US style='font-family:"Times New Roman";color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'> &quot;read line&quot;</span></code><code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>的缩写，</span></code><span
class=SpellE><code><b><span lang=EN-US style='font-size:14.5pt;color:#002222;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>readln</span></b></code></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>()</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>读取到行尾。不同的是没有</span></code><tt><span lang=EN-US style='font-size:
10.0pt;color:red;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&quot; %s&quot;</span></tt><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>格式字符串以及</span></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code><b><span lang=EN-US style='color:#002222;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&amp;</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>操作符：</span></code><span class=MsoHyperlink><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=GramE><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>import</span></span></span><span
lang=EN-US style='color:black'> <span class=SpellE>std.stdio</span>;</span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
class=GramE><span style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>void</span></span></span><span lang=EN-US style='color:black'> main()<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'>{<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px'><span class=GramE><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>char</span><span lang=EN-US style='color:black'>[</span></span><span
lang=EN-US>] name;<o:p></o:p></span></pre></span><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>write(</span></span><span style='outline: 0px'><span lang=EN-US
style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&quot;What is your name? &quot;</span></span><span
lang=EN-US style='color:black'>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px'><span class=SpellE><span class=GramE><span lang=EN-US
style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm;background:#FFFF88'>readln</span></span></span><span
class=GramE><span lang=EN-US style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;background:#FFFF88'>(</span></span><span
lang=EN-US style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;background:#FFFF88'>name)</span></span><span
lang=EN-US style='color:black'>;<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;Hello &quot;</span></span><span
lang=EN-US style='color:black'>, name, </span><span style='outline: 0px'><span
lang=EN-US style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;!&quot;</span></span><span
lang=EN-US style='color:black'>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'>}<o:p></o:p></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;mso-line-height-alt:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='mso-spacerun:yes'> </span><span class=SpellE>readln</span>()</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=HTMLChar><span style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>能存储新行字符。这就让程序有办法确定输入是否包含一条完整语句或者输入是否已结束：</span></span><code><b><span
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'> </span></b></code><span class=MsoHyperlink><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#E0E0E0;
margin-left:12.0pt;margin-right:12.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:#E0E0E0;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>What is your name? <span
class=SpellE>Mert</span></span></b><b><span lang=EN-US style='font-size:10.0pt'><o:p></o:p></span></b></pre><pre
style='margin-top:6.0pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;
background:#E0E0E0;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><b><span lang=EN-US
style='font-size:10.0pt;color:black'>Hello <span class=SpellE>Mert</span><o:p></o:p></span></b></pre><pre
style='background:#E0E0E0;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>! <span style='mso-spacerun:yes'> </span></span></b><span
style='outline: 0px'><b><span style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>← 感叹号前是新行符</span></b><b><span
lang=EN-US style='font-size:10.0pt;color:black'><o:p></o:p></span></b></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span class=HTMLChar>字符串尾端的这种控制字符能被</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=SpellE><code style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>std.string.chomp</span></b></code></span><span
class=HTMLChar>移除</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>：</span><span class=MsoHyperlink><span lang=EN-US
style='font-family:"Times New Roman";color:black;text-decoration:none;
text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=GramE><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>import</span></span></span><span
lang=EN-US style='color:black'> <span class=SpellE>std.stdio</span>;</span><span
lang=EN-US><o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:blue;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'><span
style='outline: 0px'>import</span></span></span></span><span lang=EN-US
style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm;background:#FFFF88'> <span class=SpellE>std.string</span>;</span><span
lang=EN-US style='color:black'><o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:blue;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>void</span></span></span><span
lang=EN-US style='color:black'> main()<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'>{<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px'><span class=GramE><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>char</span><span lang=EN-US style='color:black'>[</span></span><span
lang=EN-US>] name;<o:p></o:p></span></pre></span><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>write(</span></span><span style='outline: 0px'><span lang=EN-US
style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&quot;What is your name? &quot;</span></span><span
lang=EN-US style='color:black'>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>readln</span></span><span class=GramE>(</span>name);<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px'><span class=GramE><span lang=EN-US style='font-size:10.0pt;
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm;background:#FFFF88'>name</span></span><span lang=EN-US
style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm;background:#FFFF88'> = chomp(name);</span></span><span
lang=EN-US style='color:black'><o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;Hello &quot;</span></span><span
lang=EN-US style='color:black'>, name, </span><span style='outline: 0px'><span
lang=EN-US style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;!&quot;</span></span><span
lang=EN-US style='color:black'>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'>}<o:p></o:p></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>上边的</span><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>chomp()</span></b></code><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>表达式返回一个不包含尾随控制字符的新字符串。</span></span><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>返回值赋值给</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>name</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>，得到预期的输出：</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#E0E0E0;
margin-left:12.0pt;margin-right:12.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:#E0E0E0;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>What is your name? <span
class=SpellE>Mert</span></span></b><b><span lang=EN-US style='font-size:10.0pt'><o:p></o:p></span></b></pre><pre
style='background:#E0E0E0;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>Hello <span class=SpellE>Mert</span>!<span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span></b><span
style='outline: 0px'><b><span style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>← 没有新行符</span></b><b><span
lang=EN-US style='font-size:10.0pt;color:black'><o:p></o:p></span></b></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;mso-line-height-alt:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span class=SpellE><code><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>readln</span></b></code></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>()</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>没有参数也可以使用。在这情况下它返回刚刚读入的行。链接</span></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><span class=SpellE><code><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>readln</span></b></code></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>()</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></span><code><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>的结果到</span></code><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>chomp()</span></b></code><span class=apple-converted-space><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>，</span></span><code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>能得到更短且可读性更好的语法：</span></code><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:9.0pt;margin-left:0cm;background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>string</span> name = chomp(<span class=SpellE>readln</span>());<span
class=MsoHyperlink><span style='color:black;text-decoration:none;text-underline:
none'><o:p></o:p></span></span></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span lang=EN-US style='font-family:"Times New Roman";
color:black'>//</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>在介绍了下面的</span><span style='font-family:"Times New Roman";
color:black'> </span><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>string</span></b></code><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>类型后，我将开始使用那个窗体。</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<h5 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='font-size:15.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033'>双引号</span><span
lang=EN-US style='font-size:15.0pt;font-family:Arial;color:#000033'>, </span><span
style='font-size:15.0pt;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;color:#000033'>不是单引号</span><span class=MsoHyperlink><span
lang=EN-US style='font-size:15.0pt;font-family:Arial;color:#000033;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></h5>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>我们已经知道单引号用于定义字符，字符串用双引号定义。</span><span lang=EN-US
style='font-family:"Times New Roman";color:black'>'a'&nbsp;</span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>是一个字符，</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;&quot;a&quot;</span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>是包含单个字符的字符串。</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<h5 style='margin-top:0cm;margin-right:6.0pt;margin-bottom:0cm;margin-left:
6.0pt;margin-bottom:.0001pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><span lang=EN-US
style='font-size:18.0pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>string</span></code><code><span lang=EN-US
style='font-size:15.0pt;font-family:Arial;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>,</span></code><span
class=apple-converted-space><span lang=EN-US style='font-size:15.0pt;
font-family:Arial;color:#000033;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&nbsp;</span></span><span class=SpellE><code><span
lang=EN-US style='font-size:18.0pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>wstring</span></code></span><code><span
lang=EN-US style='font-size:15.0pt;font-family:Arial;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>, </span></code><code><span
style='font-size:15.0pt;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>和</span></code><span
class=apple-converted-space><span lang=EN-US style='font-size:15.0pt;
font-family:Arial;color:#000033;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&nbsp;</span></span><span class=SpellE><code><span
lang=EN-US style='font-size:18.0pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>dstring</span></code></span><span
class=apple-converted-space><span lang=EN-US style='font-size:15.0pt;
font-family:Arial;color:#000033;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&nbsp;</span></span><code><span
style='font-size:15.0pt;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>是不可变的</span></code><span
class=MsoHyperlink><span lang=EN-US style='font-size:15.0pt;font-family:Arial;
color:#000033;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm;text-decoration:none;text-underline:none'><o:p></o:p></span></span></h5>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>有三个字符串类型，它们对应着三个字符类型：</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>char[]</span></b></code><span
lang=EN-US style='font-family:"Times New Roman";color:black'>,<span
class=apple-converted-space>&nbsp;</span></span><span class=SpellE><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>wchar</span></b></code></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>[]</span></b></code><span
lang=EN-US style='font-family:"Times New Roman";color:black'>, </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>和</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=SpellE><code style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>dchar</span></b></code></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>[]</span></b></code><span
lang=EN-US style='font-family:"Times New Roman";color:black'>.<span
class=MsoHyperlink><span style='color:black;text-decoration:none;text-underline:
none'><o:p></o:p></span></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>它们三个的不可变版本类型的别名是：</span><code><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>string</span></b></code><span lang=EN-US
style='font-family:"Times New Roman";color:black'>,<span
class=apple-converted-space>&nbsp;</span></span><span class=SpellE><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>wstring</span></b></code></span><span
lang=EN-US style='font-family:"Times New Roman";color:black'>, </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>和</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=SpellE><code style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>dstring</span></b></code></span><span
lang=EN-US style='font-family:"Times New Roman";color:black'>. </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>由这些别名定义的变量的字符不能被修改。例如，可以修改一个</span><span
class=SpellE><code><b><span lang=EN-US style='font-size:14.5pt;color:#002222;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>wchar</span></b></code></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>[]</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=apple-converted-space><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>，但不可以修改一个</span></span><span
class=SpellE><code><b><span lang=EN-US style='font-size:14.5pt;color:#002222;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>wstring</span></b></code></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=apple-converted-space><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>。</span></span><span
lang=EN-US style='font-family:"Times New Roman";color:black'> (</span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>在后面的章节我们将看到</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'> D</span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>的</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=GramE><i style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>不</span></i></span><i><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>可变性</span></i><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>概念。</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'>)<span class=MsoHyperlink><span style='color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>例如，下面这段代码尝试着修改</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>字符串</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=apple-converted-space><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>的首字母为大写，将引发编译错误：</span></span><span
style='font-family:"Times New Roman";color:black'> <span class=MsoHyperlink><span
lang=EN-US style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>string</span> <span class=SpellE>canNotBeMutated</span> = </span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;hello&quot;</span></span><span
lang=EN-US style='color:black'>;</span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE>canNotBeMutated</span>[0] = 'H';<span style='mso-spacerun:yes'>            </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px'><span class=dcomment><span lang=EN-US style='font-size:
10.0pt;color:green;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>// </span></span><span class=dcomment><span style='font-size:10.0pt;
color:green;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>←</span></span><span class=dhata><span style='font-size:10.0pt;
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm;background:#FF4040'>编译错误</span></span><span lang=EN-US
style='color:black'><o:p></o:p></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>我们要是把变量定义为</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>char[]</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>而不是</span><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>string</span></b></code><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>，那就不能通过编译：</span><span
style='font-family:"Times New Roman";color:black'> <span class=MsoHyperlink><span
lang=EN-US style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
lang=EN-US style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'>char</span></span><span
lang=EN-US style='color:black'>[] <span class=SpellE>a_slice</span> = </span><span
lang=EN-US style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'>&quot;</span></span><span
lang=EN-US style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>hello</span><span lang=EN-US
style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&quot;</span><span lang=EN-US
style='color:black'>; <span style='mso-spacerun:yes'> </span></span><span
class=dcomment><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span lang=EN-US style='font-size:10.0pt;
color:green;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>// </span></span></span><span class=dcomment><span
style='font-size:10.0pt;color:green;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>←</span></span><span class=dhata><span
style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm;background:#FF4040'>编译错误</span></span><span
class=dhata><span lang=EN-US style='font-size:10.0pt;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;background:#FF4040'><o:p></o:p></span></span></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>这次的编译错误是因为两个因素碰了头：</span><span class=MsoHyperlink><span
lang=EN-US style='font-family:"Times New Roman";color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></p>

<p class=MsoNormal style='margin-right:12.0pt;text-indent:9.0pt;line-height:
14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>1</span></span><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>、</span></span><tt><span lang=EN-US style='font-size:10.0pt;
color:red;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&quot;hello&quot;</span></span></tt><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>的类型是</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>string</span></b></code><span
lang=EN-US style='font-family:"Times New Roman";color:black'>, </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>而不是</span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>char[]</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>，因此不可变。</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<p class=MsoNormal style='margin-top:0cm;margin-right:12.0pt;margin-bottom:
0cm;margin-left:9.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>2</span></span><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>、左侧的</span></span><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>char[]</span></b></code><span class=apple-converted-space><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>是一个切片</span></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>，代码编译时，它会访问右侧的全部字符。</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>错误的原因就是</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>char[]</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>可变而</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>string</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>不是。编译器不允许通过可变的切片访问不可变的数组。</span><span class=MsoHyperlink><span
lang=EN-US style='font-family:"Times New Roman";color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>这儿的解决办法是通过</span><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>.dup</span></b></code><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>属性</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>得到一个不可变字符串的副本：</span><span class=MsoHyperlink><span lang=EN-US
style='font-family:"Times New Roman";color:black;text-decoration:none;
text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>import</span></span><span
lang=EN-US style='color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'> <span class=SpellE>std.stdio</span>;</span><span
class=MsoHyperlink><span lang=EN-US style='color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'><o:p></o:p></span></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=MsoHyperlink><span
lang=EN-US style='color:black;text-decoration:none;text-underline:none'><o:p>&nbsp;</o:p></span></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
class=GramE><span lang=EN-US style='color:black'>void</span></span><span
lang=EN-US style='color:black'> main()<span class=MsoHyperlink><span
style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'>{<span class=MsoHyperlink><span
style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
class=GramE><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span lang=EN-US style='font-size:10.0pt;
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>char</span></span><span lang=EN-US style='color:black'>[</span></span><span
lang=EN-US style='color:black'>] s = </span><span lang=EN-US style='font-size:
10.0pt;color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'>&quot;</span></span><span class=SpellE><span
lang=EN-US style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>hello</span><span lang=EN-US
style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&quot;<span style='background:#FFFF88'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'>.dup</span></span></span></span><span
lang=EN-US style='color:black'>;<span class=MsoHyperlink><span
style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>s[</span>0] = 'H';<span class=MsoHyperlink><span style='color:black;
text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(s)</span>;<span
class=MsoHyperlink><span style='color:black;text-decoration:none;text-underline:
none'><o:p></o:p></span></span></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'>}<span class=MsoHyperlink><span style='color:black;
text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>程序现在能通过编译并且打印修改后的字符串。</span><span class=MsoHyperlink><span
lang=EN-US style='font-family:"Times New Roman";color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#E0E0E0;
margin-left:12.0pt;margin-right:12.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:#E0E0E0;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>Hello<span class=MsoHyperlink><span
style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></b></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>同样的，</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>char[]</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>不能被用到需要</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>string</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>的地方。这种情况下，</span><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>.<span class=SpellE>idup</span></span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=apple-converted-space><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>属性</span></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>能被用来</span><span
style='font-family:"Times New Roman";color:black'> </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>从一个可变的</span><code><b
style='mso-bidi-font-weight:normal'><span lang=EN-US style='font-size:14.5pt'>char[]</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>变量产生一个不可变的</span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>string</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>变量。例如，如果</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>s</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>是可变类型</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>char[]</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>，下面的行不能通过编译：</span><span
style='font-family:"Times New Roman";color:black'> <span class=MsoHyperlink><span
lang=EN-US style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
style='border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>string result = s ~ '.'</span>; <span style='mso-spacerun:yes'> </span></span><span
class=dcomment><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span lang=EN-US style='font-size:10.0pt;
color:green;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>// </span></span></span><span class=dcomment><span
style='font-size:10.0pt;color:green;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>←</span></span><span class=dhata><span
style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm;background:#FF4040'>编译错误</span></span><span
class=MsoHyperlink><span lang=EN-US style='font-size:10.0pt;color:windowtext;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
background:#FF4040;text-decoration:none;text-underline:none'><o:p></o:p></span></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>当</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>s</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>的类型是</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>char[]</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>，上面右侧分配的表达式的类型也是</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>char[]</span></b></code><span
class=apple-converted-space><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>。</span></span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>.<span class=SpellE>idup</span></span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>被用来<span class=GramE>从存在</span>的字符产生不可变的字符串：</span><span
style='font-family:"Times New Roman";color:black'> <span class=MsoHyperlink><span
lang=EN-US style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span>string result = (s ~ '.')</span><span
lang=EN-US style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;background:#FFFF88'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'>.<span
class=SpellE>idup</span></span></span><span lang=EN-US style='color:black'>;<span style='mso-spacerun:yes'>  </span><span style='mso-spacerun:yes'> </span></span><span
lang=EN-US style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'>// </span></span><span
style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>← 通过编译</span><span class=MsoHyperlink><span
lang=EN-US style='font-size:10.0pt;color:green;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'><o:p></o:p></span></span></pre></div>

<h5 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='font-size:15.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033'>潜在的让人迷惑的字符串的长度</span><span
class=MsoHyperlink><span lang=EN-US style='font-size:15.0pt;font-family:Arial;
color:#000033;text-decoration:none;text-underline:none'><o:p></o:p></span></span></h5>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>我们已经知道一些</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'>Unicode </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>字符串由多个字节表示。例如，字母</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'> é </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>由两个字节表示。这个事实反映在字符串的</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>.length</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=apple-converted-space><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>属性上：</span></span><span
style='font-family:"Times New Roman";color:black'> <span class=MsoHyperlink><span
lang=EN-US style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE>writeln</span>(</span><span lang=EN-US style='font-size:10.0pt;
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'>&quot;</span></span><span lang=EN-US
style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>r</span><span style='font-size:10.0pt;
color:red;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>é<span lang=EN-US>sum</span>é</span><span lang=EN-US
style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&quot;.length</span><span lang=EN-US
style='color:black'>);<span class=MsoHyperlink><span style='color:black;
text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>虽然</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'> &quot;résumé&quot; </span><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>包含六个<i><span style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>字母</span></i></span><span
style='font-family:"Times New Roman";color:black'> </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>，但是字符串的长度是它包含的</span><i><span
style='mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>字符</span></i><span lang=EN-US
style='font-family:"Times New Roman";color:black'><span
style='mso-spacerun:yes'>  </span></span><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>数：</span><span class=MsoHyperlink><span
lang=EN-US style='font-family:"Times New Roman";color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#E0E0E0;
margin-left:12.0pt;margin-right:12.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:#E0E0E0;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>8<span class=MsoHyperlink><span
style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></b></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>像</span><tt><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;hello&quot;</span></tt><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=apple-converted-space><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>这样的字符串数组的元素类型</span></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>是</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>char</span></b></code><code><b><span
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>，</span></b></code><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>并且</span><span style='font-family:"Times New Roman";
color:black'> </span><code><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>char</span></b></code><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>表示一个</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'> UTF-8 </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>编码单元。当我们试图用一个单字节字母替换一个双字节字母时问题就来了：</span><span
style='font-family:"Times New Roman";color:black'> </span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span style='mso-spacerun:yes'> </span></span></span><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px'>char</span></span><span
lang=EN-US style='color:black'>[] s = </span><span lang=EN-US style='font-size:
10.0pt;color:red;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='outline: 0px'>&quot;r</span></span><span
style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>é<span lang=EN-US>sum</span>é<span lang=EN-US>&quot;</span></span><span
lang=EN-US style='font-size:10.0pt;color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>.<span class=GramE>dup</span></span><span
lang=EN-US style='color:black'>;<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;Before: &quot;</span></span><span
lang=EN-US style='color:black'>, s);<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>s[</span>1] = 'e';<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>s[</span>5] = 'e';<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;After : &quot;</span></span><span
lang=EN-US style='color:black'>, s);<span class=MsoHyperlink><span
style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>两个</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'> 'e' </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>字符不能替换两个字母</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'> é</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>；替换后，就会得到一个不正确的</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'>UTF-8</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>编码：</span><span style='font-family:"Times New Roman";color:black'>
<span class=MsoHyperlink><span lang=EN-US style='color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#E0E0E0;
margin-left:12.0pt;margin-right:12.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:#E0E0E0;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>Before: r</span></b><b><span
style='font-size:10.0pt;color:black'>é<span lang=EN-US>sum</span>é<span
class=MsoHyperlink><span lang=EN-US style='color:black;text-decoration:none;
text-underline:none'><o:p></o:p></span></span></span></b></pre><pre
style='background:#E0E0E0;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>After : <span class=SpellE>re<span
style='font-family:Tahoma'>�</span>sue</span></span></b><b><span
style='font-size:10.0pt;color:black'>é<span lang=EN-US><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'><span style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'>←</span> </span></span></b><b><span
style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>不正确</span></b><span class=MsoHyperlink><b><span
lang=EN-US style='font-size:10.0pt;color:black;text-decoration:none;text-underline:
none'><o:p></o:p></span></b></span></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>像上面的代码那样直接处理字母、符号以及其它</span><span lang=EN-US style='font-family:
"Times New Roman";color:black'>Unicode </span><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>字符串的正确类型是使用</span><span class=SpellE><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>dchar</span></b></code></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>：</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>   </span></span><span
class=SpellE><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>dchar</span></span><span
lang=EN-US style='color:black'>[] s = </span><span style='outline: 0px'><span
lang=EN-US style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;r</span><span
style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>é<span lang=EN-US>sum</span>é<span lang=EN-US>&quot;<span
class=SpellE>d<span style='font-size:12.0pt;color:black'>.<span class=GramE>dup</span></span></span></span></span></span><span
lang=EN-US style='color:black'>;</span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;Before: &quot;</span></span><span
lang=EN-US style='color:black'>, s);<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>s[</span>1] = 'e';<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>s[</span>5] = 'e';<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;After : &quot;</span></span><span
lang=EN-US style='color:black'>, s);<span class=MsoHyperlink><span
style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>输出：</span><span style='font-family:"Times New Roman";color:black'>
<span class=MsoHyperlink><span lang=EN-US style='color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#E0E0E0;
margin-left:12.0pt;margin-right:12.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:#E0E0E0;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>Before: r</span></b><b><span
style='font-size:10.0pt;color:black'>é<span lang=EN-US>sum</span>é<span
class=MsoHyperlink><span lang=EN-US style='color:black;text-decoration:none;
text-underline:none'><o:p></o:p></span></span></span></b></pre><pre
style='margin-top:6.0pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;
background:#E0E0E0;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><b><span
lang=EN-US style='font-size:10.0pt;color:black'>After :</span></b></span><b><span
lang=EN-US style='font-size:10.0pt;color:black'> resume<span
class=MsoHyperlink><span style='color:black;text-decoration:none;text-underline:
none'><o:p></o:p></span></span></span></b></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>请注意在新代码中的两个不同：</span><span style='font-family:"Times New Roman";
color:black'> <span class=MsoHyperlink><span lang=EN-US style='color:black;
text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></p>

<p class=MsoNormal style='margin-top:0cm;margin-right:12.0pt;margin-bottom:
0cm;margin-left:18.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:
45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span lang=EN-US style='font-family:"Times New Roman";
color:black'>1</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>、字符串的类型是</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
class=SpellE><code style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>dchar</span></b></code></span><code><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>[]</span></b></code><code><b><span
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>。</span></b></code><span class=MsoHyperlink><span
lang=EN-US style='font-family:"Times New Roman";color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></p>

<p class=MsoNormal style='margin-top:0cm;margin-right:12.0pt;margin-bottom:
0cm;margin-left:18.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:
45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span lang=EN-US style='font-family:"Times New Roman";
color:black'>2</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>、字符串</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><tt
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'>&quot;<span
class=SpellE>résumé&quot;d</span></span></span></tt><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>的结尾还有一个</span><code><b style='mso-bidi-font-weight:
normal'><span lang=EN-US style='font-size:14.5pt'>d</span></b></code><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>，</span><span
style='font-family:"Times New Roman";color:black'> </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>指定了它的类型是</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=SpellE><code style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>dchar</span></b></code></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>数组。</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<h5 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='font-size:15.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033'>字符串文本</span><span
class=MsoHyperlink><span lang=EN-US style='font-size:15.0pt;font-family:Arial;
color:#000033;text-decoration:none;text-underline:none'><o:p></o:p></span></span></h5>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>在字符串元素类型确定后，可选的字符集就被指定了。</span><span class=MsoHyperlink><span
lang=EN-US style='font-family:"Times New Roman";color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=GramE><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>import</span></span></span><span
lang=EN-US style='color:black'> <span class=SpellE>std.stdio</span>;<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
class=GramE><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'><span style='outline: 0px'>void</span></span></span><span
lang=EN-US style='color:black'> main()<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'>{<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>     </span>string s = </span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;<span
class=SpellE>résumé&quot;c</span></span></span><span lang=EN-US
style='color:black'>;<span style='mso-spacerun:yes'>  </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:green;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>// </span><span
style='font-size:10.0pt;color:green;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>等同于<span lang=EN-US> &quot;résumé&quot;<o:p></o:p></span></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>wstring</span></span> w = </span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;<span
class=SpellE>résumé&quot;w</span></span></span><span lang=EN-US
style='color:black'>;<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>dstring</span></span> d = </span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;<span
class=SpellE>résumé&quot;d</span></span></span><span lang=EN-US
style='color:black'>;<o:p></o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span><span
class=SpellE>s.length</span>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span><span
class=SpellE>w.length</span>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span><span
class=SpellE>d.length</span>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'>}<o:p></o:p></span></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
0cm;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span lang=EN-US style='font-family:"Times New Roman";
color:black'><span style='mso-spacerun:yes'>   </span></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>输出：</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#E0E0E0;
margin-left:12.0pt;margin-right:12.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:#E0E0E0;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>8<span class=MsoHyperlink><span
style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></b></pre><pre
style='margin-top:6.0pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;
background:#E0E0E0;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><b><span lang=EN-US
style='font-size:10.0pt;color:black'>6<span class=MsoHyperlink><span
style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></b></pre><pre
style='margin-top:6.0pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;
background:#E0E0E0;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><b><span lang=EN-US
style='font-size:10.0pt;color:black'>6<span class=MsoHyperlink><span
style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></b></pre></div>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>因为</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&quot;résumé&quot;</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>的全部字母都能用单个</span><span style='font-family:"Times New Roman";
color:black'> </span><span class=SpellE><code><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>wchar</span></b></code></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>或者</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
class=SpellE><code style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>dchar</span></b></code></span><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>表示，所以后两个的长度和字母数一致。</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<h5 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='font-size:15.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033'>字符串串联</span><span
class=MsoHyperlink><span lang=EN-US style='font-size:15.0pt;font-family:Arial;
color:#000033;text-decoration:none;text-underline:none'><o:p></o:p></span></span></h5>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>字符串也是数组，数组的全部操作一样也能应用到字符串上。</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>~</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>串联两个字符串</span><span style='font-family:"Times New Roman";
color:black'> </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>，</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>~=</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>追加到一个已存在的字符串。</span><span class=MsoHyperlink><span lang=EN-US
style='font-family:"Times New Roman";color:black;text-decoration:none;
text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=GramE><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>import</span></span></span><span
lang=EN-US style='color:black'> <span class=SpellE>std.stdio</span>;</span><span
lang=EN-US><o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:blue;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>import</span></span></span><span
lang=EN-US style='color:black'> <span class=SpellE>std.string</span>;<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
class=GramE><span style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>void</span></span></span><span lang=EN-US style='color:black'> main()<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'>{<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>write(</span></span><span style='outline: 0px'><span lang=EN-US
style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&quot;What is your name? &quot;</span></span><span
lang=EN-US style='color:black'>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>string</span> name = chomp(<span class=SpellE>readln</span>());<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:green;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>// Concatenate:<o:p></o:p></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>string</span> greeting = </span><span style='outline: 0px'><span
lang=EN-US style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;Hello &quot;</span></span><span
lang=EN-US style='color:black'> ~ name;<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:green;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>// Append:<o:p></o:p></span></pre></span><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>greeting</span> ~= </span><span style='outline: 0px'><span
lang=EN-US style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;! Welcome...<span
class=GramE>&quot;<span style='font-size:12.0pt;color:black'>;</span></span></span></span><span
lang=EN-US style='color:black'><o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span>greeting);<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'>}<o:p></o:p></span></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>输出：</span><span style='font-family:"Times New Roman";color:black'>
<span class=MsoHyperlink><span lang=EN-US style='color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:#E0E0E0;
margin-left:12.0pt;margin-right:12.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:#E0E0E0;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><b><span
lang=EN-US style='font-size:10.0pt;color:black'>What is your name? Can<span
class=MsoHyperlink><span style='color:black;text-decoration:none;text-underline:
none'><o:p></o:p></span></span></span></b></pre><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;background:#E0E0E0;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><b><span lang=EN-US
style='font-size:10.0pt;color:black'>Hello Can! Welcome...<span
class=MsoHyperlink><span style='color:black;text-decoration:none;text-underline:
none'><o:p></o:p></span></span></span></b></pre></div>

<h5 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='font-size:15.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033'>比较字符串</span><span
class=MsoHyperlink><span lang=EN-US style='font-size:15.0pt;font-family:Arial;
color:#000033;text-decoration:none;text-underline:none'><o:p></o:p></span></span></h5>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><b style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><i style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>注</span></i></b><b><i><span
lang=EN-US style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>:</span></i></b><span
class=apple-converted-space><i><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></i></span><i><span lang=EN-US style='font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>Unicode </span></i><i><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>不定义编码字符间的排序方式，因而，下面的输出结果不是你所期望的。当字母顺序很重要时，你可以使用一个像</span></i><span
class=apple-converted-space><i><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></i></span><span class=SpellE><i><span lang=EN-US
style='font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>trileri</span></i></span><span
class=apple-converted-space><i><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>&nbsp;</span></i></span><span class=apple-converted-space><i><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>那样支持字母表概念的库。</span></i></span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>我们以前把比较运算符</span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&lt;</span></b></code><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>，</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><code style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&gt;=</span></b></code><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>，等等</span><span style='font-family:"Times New Roman";
color:black'> </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>用于整数和浮点数。同样的操作也能用于字符串，但含义不同：字符串按</span><span style='font-family:
"Times New Roman";color:black'> </span><i><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>字典顺序</span></i><span style='font-family:"Times New Roman";
color:black'> </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>排序。这种排序需要在一个假设的大字母表中让每个字符的</span><span lang=EN-US
style='font-family:"Times New Roman";color:black'> Unicode </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>编码找到它的位置。在这个假设的字母表中，<i
style='mso-bidi-font-style:normal'>更少</i></span><i style='mso-bidi-font-style:
normal'><span style='font-family:"Times New Roman";color:black'> </span></i><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>或</span><span
style='font-family:"Times New Roman";color:black'> </span><i style='mso-bidi-font-style:
normal'><span style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";mso-bidi-font-family:"Times New Roman";color:black'>更多</span></i><i
style='mso-bidi-font-style:normal'><span style='font-family:"Times New Roman";
color:black'> </span></i><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>的概念就被</span><span style='font-family:"Times New Roman";color:black'>
</span><i style='mso-bidi-font-style:normal'><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>之前</span></i><i style='mso-bidi-font-style:normal'><span
style='font-family:"Times New Roman";color:black'> </span></i><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>或</span><span
style='font-family:"Times New Roman";color:black'> </span><i style='mso-bidi-font-style:
normal'><span style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";mso-bidi-font-family:"Times New Roman";color:black'>之后</span></i><i
style='mso-bidi-font-style:normal'><span style='font-family:"Times New Roman";
color:black'> </span></i><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>替换。</span><span class=MsoHyperlink><span lang=EN-US
style='font-family:"Times New Roman";color:black;text-decoration:none;
text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;orphans: auto;
text-align:start;widows: auto;-webkit-text-stroke-width: 0px;background-position:
initial initial;background-repeat:initial initial;word-spacing:0px'><span
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
class=GramE><span lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>import</span></span></span><span
lang=EN-US style='color:black'> <span class=SpellE>std.stdio</span>;</span><span
lang=EN-US><o:p></o:p></span></pre><pre style='background:white;vertical-align:
baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;padding:0cm;
mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span class=GramE><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:blue;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>import</span></span></span><span
lang=EN-US style='color:black'> <span class=SpellE>std.string</span>;<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
class=GramE><span style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>void</span></span></span><span lang=EN-US style='color:black'> main()<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'>{<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>write(</span></span><span style='outline: 0px'><span lang=EN-US
style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&quot;<span style='mso-spacerun:yes'>      </span>Enter a string: &quot;</span></span><span
lang=EN-US style='color:black'>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>string</span> s1 = chomp(<span class=SpellE>readln</span>());<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>write(</span></span><span style='outline: 0px'><span lang=EN-US
style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>&quot;Enter another string: &quot;</span></span><span
lang=EN-US style='color:black'>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=GramE>string</span> s2 = chomp(<span class=SpellE>readln</span>());<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>   </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px'><span class=GramE><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>if</span></span></span><span lang=EN-US style='color:black'> (s1 </span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
background:#FFFF88'>==</span></span><span lang=EN-US style='color:black'> s2) {<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>        </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;They are the same!&quot;</span></span><span
lang=EN-US style='color:black'>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span>} </span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:blue;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>else</span></span><span
lang=EN-US style='color:black'> {<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>  </span><span style='mso-spacerun:yes'> </span><span style='mso-spacerun:yes'>     </span><span
class=GramE>string</span> former;<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>        </span><span
class=GramE>string</span> latter;<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>  </span><span style='mso-spacerun:yes'> </span><span style='mso-spacerun:yes'>    </span><span style='mso-spacerun:yes'> </span></span><span
style='outline: 0px'><span class=GramE><span lang=EN-US style='font-size:10.0pt;
color:blue;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>if</span></span></span><span lang=EN-US style='color:black'> (s1 </span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:black;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
background:#FFFF88'>&lt;</span></span><span lang=EN-US style='color:black'> s2) {<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>            </span><span
class=GramE>former</span> = s1;<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>            </span><span
class=GramE>latter</span> = s2;<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><o:p>&nbsp;</o:p></span></pre><pre style='background:white;
vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>        </span>} </span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:blue;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>else</span></span><span
lang=EN-US style='color:black'> {<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>      </span><span style='mso-spacerun:yes'> </span><span style='mso-spacerun:yes'>     </span><span
class=GramE>former</span> = s2;<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>            </span><span
class=GramE>latter</span> = s1;<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>        </span>}<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><o:p>&nbsp;</o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'><span style='mso-spacerun:yes'>  </span><span style='mso-spacerun:yes'> </span><span style='mso-spacerun:yes'>     </span><span
class=SpellE><span class=GramE>writeln</span></span><span class=GramE>(</span></span><span
style='outline: 0px'><span lang=EN-US style='font-size:10.0pt;color:red;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;'&quot;</span></span><span
lang=EN-US style='color:black'>, former, </span><span style='outline: 0px'><span
lang=EN-US style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;' comes before '&quot;</span></span><span
lang=EN-US style='color:black'>, latter, </span><span style='outline: 0px'><span
lang=EN-US style='font-size:10.0pt;color:red;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>&quot;'.&quot;</span></span><span
lang=EN-US style='color:black'>);<o:p></o:p></span></pre><pre style='background:
white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span>}<o:p></o:p></span></pre><pre
style='background:white;vertical-align:baseline;border:none;mso-border-alt:
dotted #99CC99 .75pt;padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span
lang=EN-US style='color:black'>}<o:p></o:p></span></pre></div>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>由于</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'>Unicode</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>采用来自于</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'>ASCII </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>表的基本拉丁字母，只包含</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'>ASCII </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>字母的字符串似乎正确排序。</span><span class=MsoHyperlink><span lang=EN-US
style='font-family:"Times New Roman";color:black;text-decoration:none;
text-underline:none'><o:p></o:p></span></span></p>

<h5 style='margin-top:15.0pt;margin-right:6.0pt;margin-bottom:6.0pt;margin-left:
6.0pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='font-size:15.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033'>小写和大写不同</span><span
class=MsoHyperlink><span lang=EN-US style='font-size:15.0pt;font-family:Arial;
color:#000033;text-decoration:none;text-underline:none'><o:p></o:p></span></span></h5>

<p style='margin-top:9.0pt;margin-right:12.0pt;margin-bottom:9.0pt;margin-left:
12.0pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>因为每个字母都有一个唯一的编码，每个字母都有别于其它。例如，</span><span lang=EN-US
style='font-family:"Times New Roman";color:black'> 'A' </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>和</span><span lang=EN-US
style='font-family:"Times New Roman";color:black'> 'a' </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>是不同的字母。</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>另外，受</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'>ASCII</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>编码值的影响，所有大写字母的排序都在小写字母之前。例如，</span><span lang=EN-US
style='font-family:"Times New Roman";color:black'> 'B' </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>在</span><span lang=EN-US
style='font-family:"Times New Roman";color:black'> 'a'</span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>之前。</span><span
class=SpellE><b style='mso-bidi-font-weight:normal'><span lang=EN-US
style='font-size:13.5pt;mso-bidi-font-family:"Times New Roman";color:black'>std.string</span></b></span><span
lang=EN-US style='mso-bidi-font-family:"Times New Roman";color:black'> </span><span
style='mso-bidi-font-family:"Times New Roman";color:black'>模块中的函数</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=SpellE><code style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>icmp</span></b></code></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>()</span></b></code><span
lang=EN-US style='font-family:"Times New Roman";color:black'> </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>可用于字符串比较，无论小写大写。</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'>. </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>在<span style='border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>联机文档</span>中你可以看到这个模块的各个函数。</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<p style='margin-top:0cm;margin-right:12.0pt;margin-bottom:0cm;margin-left:
12.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>因为字符串是数组（作个推演，</span><i style='mso-bidi-font-style:normal'><span
lang=EN-US style='font-family:"Times New Roman";color:black'>ranges</span></i><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>），</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=SpellE><code style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>std.array</span></b></code></span><span
lang=EN-US style='font-family:"Times New Roman";color:black'>,<span
class=apple-converted-space>&nbsp;</span></span><span class=SpellE><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>std.algorithm</span></b></code></span><span
lang=EN-US style='font-family:"Times New Roman";color:black'>, and<span
class=apple-converted-space>&nbsp;</span></span><span class=SpellE><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>std.range</span></b></code></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>模块中的函数对字符串一样非常有用。</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'>.<span class=MsoHyperlink><span style='color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></span></p>

<h5 style='margin-top:15.0pt;margin-right:-204.8pt;margin-bottom:6.0pt;
margin-left:6.0pt;mso-para-margin-top:15.0pt;mso-para-margin-right:-204.8pt;
mso-para-margin-bottom:6.0pt;mso-para-margin-left:.5gd;text-indent:7.4pt;
mso-char-indent-count:.49;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;orphans: auto;text-align:start;widows: auto;
-webkit-text-stroke-width: 0px;background-position:initial initial;background-repeat:
initial initial;word-spacing:0px'><span style='font-size:15.0pt;mso-ascii-font-family:
Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:Arial;color:#000033'>练习</span><span
class=MsoHyperlink><span lang=EN-US style='font-size:15.0pt;font-family:Arial;
color:#000033;text-decoration:none;text-underline:none'><o:p></o:p></span></span></h5>

<p class=MsoNormal style='margin-right:12.0pt;text-indent:6.0pt;line-height:
14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span lang=EN-US style='font-family:"Times New Roman";
color:black'>1</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>、浏览</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
class=SpellE><code style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>std.string</span></b></code></span><span lang=EN-US
style='font-family:"Times New Roman";color:black'>,<span
class=apple-converted-space>&nbsp;</span></span><span class=SpellE><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>std.array</span></b></code><span
lang=EN-US style='font-family:"Times New Roman";color:black'>,</span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>std.algorithm</span></b></code></span><span
lang=EN-US style='font-family:"Times New Roman";color:black'>, </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>和</span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span class=SpellE><code style='outline: 0px;
background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>std.range</span></b></code></span><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>模块的文档。</span><span class=MsoHyperlink><span lang=EN-US
style='font-family:"Times New Roman";color:black;text-decoration:none;
text-underline:none'><o:p></o:p></span></span></p>

<p class=MsoNormal style='margin-right:12.0pt;text-indent:6.0pt;line-height:
14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span lang=EN-US style='font-family:"Times New Roman";
color:black'>2</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>、写一个使用</span><b style='mso-bidi-font-weight:normal'><span
lang=EN-US style='font-size:14.0pt;font-family:"Times New Roman";color:black'>~</span></b><span
lang=EN-US style='font-family:"Times New Roman";color:black'> </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>运算符的程序：</span><span
style='font-family:"Times New Roman";color:black'> </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>让用户敲入名字和姓氏，都用小写，产生一个姓名首字母大写的全名。</span><span
style='font-family:"Times New Roman";color:black'> </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>例如，字符串是</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'> &quot;<span
class=SpellE>ebru</span>&quot; </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>和</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'> &quot;<span class=SpellE>domates</span>&quot; </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>，程序应该打印出</span><span
lang=EN-US style='font-family:"Times New Roman";color:black'> &quot;<span
class=SpellE>Ebru</span>&nbsp;<span class=SpellE>Domates</span>&quot;</span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>。</span><span
class=MsoHyperlink><span lang=EN-US style='font-family:"Times New Roman";
color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></p>

<p class=MsoNormal style='margin-top:6.0pt;margin-right:12.0pt;margin-bottom:
0cm;margin-left:0cm;margin-bottom:.0001pt;text-indent:6.0pt;line-height:14.25pt;
tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span lang=EN-US style='font-family:"Times New Roman";
color:black'>3</span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>、从输入中读取一行并打印该行的第一个和最后一个</span><span lang=EN-US style='font-family:
"Times New Roman";color:black'> 'e' </span><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>字母之间的部分。例如，若这行是</span><span lang=EN-US
style='font-family:"Times New Roman";color:black'> &quot;this line has five
words&quot; </span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>程序应打印出</span><span lang=EN-US style='font-family:"Times New Roman";
color:black'> &quot;e has five&quot;</span><span style='mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:
"Times New Roman";color:black'>。</span><span class=MsoHyperlink><span
lang=EN-US style='font-family:"Times New Roman";color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></p>

<p style='margin-top:0cm;margin-right:24.0pt;margin-bottom:0cm;margin-left:
42.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>你可能会发现</span><span class=SpellE><code><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>indexOf</span></b></code></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>()</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>和</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
class=SpellE><code style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>lastIndexOf</span></b></code></span><code><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>()</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>函数有利于得到两个索引值，然后产生一个切片。</span><span class=MsoHyperlink><span
lang=EN-US style='font-family:"Times New Roman";color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></p>

<p class=MsoNormal style='margin-left:21.0pt;text-indent:21.0pt;mso-pagination:
none;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
mso-layout-grid-align:none;text-autospace:none;outline: 0px;background-position:
initial initial;background-repeat:initial initial'><span style='color:black'>它们的文档指出，</span><span
class=SpellE><code><b><span lang=EN-US style='font-size:14.5pt;color:#002222;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>indexOf</span></b></code></span><code><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>()</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>和</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
class=SpellE><code style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>lastIndexOf</span></b></code></span><code><b><span lang=EN-US
style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm'>()</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>的返回值不是</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
class=SpellE><code style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><b><span lang=EN-US style='font-size:14.5pt;
color:#002222;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm'>int</span></b></code></span><span class=apple-converted-space><span
lang=EN-US style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>也不是</span><span
class=SpellE><code><b><span lang=EN-US style='font-size:14.5pt;color:#002222;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm'>size_t</span></b></code></span><span
lang=EN-US style='font-family:"Times New Roman";color:black'>, </span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>而是</span><span
class=SpellE><b style='mso-bidi-font-weight:normal'><span lang=EN-US
style='font-size:14.5pt;mso-bidi-font-family:"Times New Roman";color:black'>sizediff_t</span></b></span><span
style='mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";color:black'>。您可能也需要定义确切的变量类型：</span><span
style='font-family:"Times New Roman";color:black'> </span><span
class=MsoHyperlink><span lang=EN-US style='font-size:9.5pt;font-family:新宋体;
mso-bidi-font-family:新宋体;color:#0000A0;text-decoration:none;text-underline:
none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:42.0pt;margin-right:24.0pt'><pre style='margin-top:6.0pt;
margin-right:0cm;margin-bottom:9.0pt;margin-left:0cm;line-height:14.25pt;
background:white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>    </span><span
class=SpellE>sizediff_t</span> <span class=SpellE>first_e</span> = <span
class=SpellE><span class=GramE>indexOf</span></span><span class=GramE>(</span>line, 'e');<span
class=MsoHyperlink><span style='color:black;text-decoration:none;text-underline:
none'><o:p></o:p></span></span></span></pre></div>

<p style='margin-top:0cm;margin-right:24.0pt;margin-bottom:0cm;margin-left:
42.0pt;margin-bottom:.0001pt;line-height:14.25pt;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline;outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>也可以使用</span><span class=apple-converted-space><span lang=EN-US
style='font-family:"Times New Roman";color:black'>&nbsp;</span></span><code
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><b><span
lang=EN-US style='font-size:14.5pt;color:#002222;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>auto</span></b></code><span
class=apple-converted-space><span lang=EN-US style='font-family:"Times New Roman";
color:black'>&nbsp;</span></span><span style='mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman";
color:black'>关键字定义一个更短的变量，这个我们将在后面的章节看到。</span><span class=MsoHyperlink><span
lang=EN-US style='font-family:"Times New Roman";color:black;text-decoration:
none;text-underline:none'><o:p></o:p></span></span></p>

<div style='mso-element:para-border-div;border:dotted #99CC99 1.0pt;mso-border-alt:
dotted #99CC99 .75pt;padding:6.0pt 6.0pt 6.0pt 6.0pt;background:white;
margin-left:12.0pt;margin-right:12.0pt'><pre style='line-height:14.25pt;
background:white;vertical-align:baseline;border:none;mso-border-alt:dotted #99CC99 .75pt;
padding:0cm;mso-padding-alt:6.0pt 6.0pt 6.0pt 6.0pt;outline: 0px;background-position:
initial initial;background-repeat:initial initial'><span lang=EN-US
style='color:black'><span style='mso-spacerun:yes'>   </span><span
style='mso-tab-count:2'>          </span></span><span class=GramE><span
lang=EN-US style='font-size:10.0pt;color:blue;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm'>auto</span></span></span><span
lang=EN-US style='color:black'> <span class=SpellE>first_e</span> = <span
class=SpellE>indexOf</span>(line, 'e');<span class=MsoHyperlink><span
style='color:black;text-decoration:none;text-underline:none'><o:p></o:p></span></span></span></pre></div>

<p class=MsoNormal style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span
lang=EN-US><a href="http://ddili.org/ders/d.en/strings.cozum.html"
target="ddili_cozum" style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><i style='outline: 0px;background-position:
initial initial;background-repeat:initial initial'><span style='color:purple;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
text-decoration:none;text-underline:none'>... </span></i><i><span lang=EN-US
style='color:purple;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm;text-decoration:none;text-underline:none'><span lang=EN-US>解答</span></span></i></a></span></p>

<p class=MsoNormal align=center style='text-align:center;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
vertical-align:baseline'><span lang=EN-US style='font-size:11.0pt;font-family:
"Times New Roman";color:black'>[<span class=apple-converted-space>&nbsp;</span><a
href="slices.html" style='outline: 0px;background-position:initial initial;
background-repeat:initial initial'><span lang=EN-US style='font-size:10.5pt;
font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman";color:purple;border:none windowtext 1.0pt;mso-border-alt:
none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:none'><span
lang=EN-US>前一节</span></span><span style='font-size:10.5pt;color:purple;
border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;padding:0cm;
text-decoration:none;text-underline:none'>&nbsp;</span></a>] &nbsp; [<span
class=apple-converted-space>&nbsp;</span><a href="streamredirect.html"
style='outline: 0px;background-position:initial initial;background-repeat:initial initial'><span
lang=EN-US style='font-size:10.5pt;font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman";color:purple;border:none windowtext 1.0pt;
mso-border-alt:none windowtext 0cm;padding:0cm;text-decoration:none;text-underline:
none'><span lang=EN-US>后一节</span></span><span style='font-size:10.5pt;
color:purple;border:none windowtext 1.0pt;mso-border-alt:none windowtext 0cm;
padding:0cm;text-decoration:none;text-underline:none'>&nbsp;</span></a>]<o:p></o:p></span></p>

</span></div>

</span></span>
</body>

</html>
